﻿using System;
using System.Web;
using System.Data;
using System.Data.SqlClient;
using VIT.DataHelper.DataAccess;

namespace VIT.Business
{
    public class BLConfig
    {
        #region Entities
        public int Id { get; set; }
        public string LanguageId { get; set; }
        public string Email { get; set; }
        public string PreTemplate { get; set; }
        public string AdminTemplate { get; set; }

        SQLSupport sqlSupport = new SQLSupport();
        #endregion

        #region Constructor
        public BLConfig(string LanguageId = "",
            string Email="",
            string PreTemplate="",
            string AdminTemplate="")
        {
            this.LanguageId = LanguageId;
            this.Email = Email;
            this.PreTemplate = PreTemplate;
            this.AdminTemplate = AdminTemplate;
        }
        #endregion

        #region Methods
        public void GetConfig()
        {
            string strQuery = "select Email, PreTemplate, AdminTemplate from WebConfig where LanguageID=@LanguageId";
            SqlParameter LanguageId = new SqlParameter("@LanguageId", this.LanguageId);
            DataTable dt = sqlSupport.ExecuteDataset(false, strQuery, LanguageId).Tables[0];

            if (dt.Rows.Count > 0)
            {
                this.Email = dt.Rows[0]["Email"].ToString();
                this.PreTemplate = dt.Rows[0]["PreTemplate"].ToString();
                this.AdminTemplate = dt.Rows[0]["AdminTemplate"].ToString();
            }
        }
        #endregion
    }
}
